package com.taotao.test;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemExample;
import com.taotao.service.ItemService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import sun.rmi.log.LogInputStream;

import java.util.List;

/**
 * Created by new on 2018/6/1.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/applicationContext-*.xml"})
public class test {

    @Autowired
    private ItemService itemService;

    @Test
    public void test(){
        TbItemExample tbItemExample = new TbItemExample();
        PageHelper.startPage(1,10);
        List<TbItem> list = itemService.selectList(tbItemExample);
        System.out.print("===========================");
        for (TbItem item: list) {
            System.out.print(item.getTitle());
        }
        Page<TbItem> pageInfo = (Page<TbItem>)list;
        long total =pageInfo.getTotal();
        System.out.print("总数="+total);
        System.out.print("===========================");
    }
}
